package org.chs.ts.system.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.willa.business.sys.entity.SysUser;
import org.willa.common.vo.Result;
import org.willa.system.entity.vo.SysUserVO;
import org.willa.system.service.ISysUserService;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.List;

/**
 * @author wuwei
 * @date 2024/1/3
 * @apiNote
 */
@Api(tags = "系统用户相关功能")
@RestController
@RequestMapping("/api/v1/sysUser")
public class SysUserController {

    @Resource
    private ISysUserService sysUserService;

    /**
     * 注册用户
     */
    @ApiOperation("注册用户")
    @ApiImplicitParam(name = "sysUserInsVO", value = "用户注册对象", required = true)
    @PostMapping("/insSysUser")
    public Result insSysUser(@RequestBody @Valid SysUserVO sysUserVO) {
        return sysUserService.insertUser(sysUserVO);
    }

    /**
     * 删除用户
     */
    @ApiOperation("删除用户")
    @ApiImplicitParam(name = "sysUserInsVO", value = "用户注册对象", required = true)
    @PostMapping("/delSysUser")
    public Result delSysUser(@RequestBody @Valid SysUserVO sysUserVO) {
        return null;
    }

    /**
     * 查询用户
     */
    @ApiOperation("查询用户")
    @ApiImplicitParam(name = "sysUserInsVO", value = "用户注册对象", required = true)
    @PostMapping("/getSysUserByPara")
    public Result<IPage<SysUserVO>> getSysUserByParameter(@RequestBody SysUserVO sysUserVO, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                          @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                                          HttpServletRequest req) {
       // TODO 待前台创建后 进行实现

        return Result.ok(null);
    }

    /**
     * 查询用户列表
     */
    @ApiOperation("查询用户列表")
    @ApiImplicitParam(name = "sysUserInsVO", value = "用户注册对象", required = true)
    @PostMapping("/getSysUserListByPara")
    public Result<List<SysUserVO>> getSysUserListByParameter(@RequestBody SysUserVO sysUserVO) {
        return null;
    }
}
